Skip to content

Implement long/narrow -> short fallback in babel.units#1225

Merged
akx merged 2 commits intopython-babel:masterfrom
trillllian:master
Apr 11, 2026
Merged

Implement long/narrow -> short fallback in babel.units#1225
akx merged 2 commits intopython-babel:masterfrom
trillllian:master

Conversation

@trillllian
Copy link
Copy Markdown
Contributor

Also implemented fallback from the correct pluralization to "other", which was also missing.

Fixes #1217.

@trillllian
Copy link
Copy Markdown
Contributor Author

hi, i noticed 2.18.0 was released recently. is there any chance someone could take a look at this PR? it is really not a complicated fix in my opinion, and this bug causes quite a few strings in our application to go untranslated. (well, currently it's not much of a problem since we are using babel 2.12 which has a much older CLDR, but it would be nice to upgrade.)

thanks for all the great work on babel regardless!

@akx akx self-requested a review April 10, 2026 07:07
Copy link
Copy Markdown
Member

@akx akx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one tiny performance note.

Sorry reviewing this had fallen through the cracks!

Also implemented fallback from the correct pluralization to "other",
which was also missing.

Fixes python-babel#1217.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.05%. Comparing base (dea267e) to head (2f4059c).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1225   +/-   ##
=======================================
  Coverage   92.04%   92.05%           
=======================================
  Files          27       27           
  Lines        4715     4719    +4     
=======================================
+ Hits         4340     4344    +4     
  Misses        375      375           
Flag Coverage Δ
macos-14-3.10 91.09% <100.00%> (+<0.01%) ⬆️
macos-14-3.11 91.03% <100.00%> (+<0.01%) ⬆️
macos-14-3.12 91.24% <100.00%> (+<0.01%) ⬆️
macos-14-3.13 91.24% <100.00%> (+<0.01%) ⬆️
macos-14-3.14 91.22% <100.00%> (+<0.01%) ⬆️
macos-14-3.8 90.96% <100.00%> (+<0.01%) ⬆️
macos-14-3.9 91.03% <100.00%> (+<0.01%) ⬆️
macos-14-pypy3.10 91.09% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.10 91.12% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.11 91.05% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.12 91.26% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.13 91.26% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.14 91.24% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.8 90.98% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-3.9 91.05% <100.00%> (+<0.01%) ⬆️
ubuntu-24.04-pypy3.10 91.12% <100.00%> (+<0.01%) ⬆️
windows-2022-3.10 91.11% <100.00%> (+<0.01%) ⬆️
windows-2022-3.11 91.04% <100.00%> (+<0.01%) ⬆️
windows-2022-3.12 91.26% <100.00%> (+<0.01%) ⬆️
windows-2022-3.13 91.26% <100.00%> (+<0.01%) ⬆️
windows-2022-3.14 91.23% <100.00%> (+<0.01%) ⬆️
windows-2022-3.8 91.08% <100.00%> (+<0.01%) ⬆️
windows-2022-3.9 91.04% <100.00%> (+<0.01%) ⬆️
windows-2022-pypy3.10 91.11% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: Aarni Koskela <akx@iki.fi>
@akx akx enabled auto-merge (squash) April 11, 2026 15:47
@akx akx merged commit 345c797 into python-babel:master Apr 11, 2026
31 checks passed
@trillllian
Copy link
Copy Markdown
Contributor Author

Thank you so much!

Do you have any plans regarding when the next release will be? I have a project where I've been putting off updating Babel specifically because of this bug, so it would be nice to have a release with the fix included... I was thinking maybe you could do a 2.18.1 when you're done with all the small bugfix PRs? No rush if you have other plans though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

babel.units.format_unit does not fall back from long to short correctly

2 participants